#include"Solution.h"

int maxDepth(BTNode* root) {
    if (root == NULL)
    {
        return 0;
    }

    int leftDepth = maxDepth(root->left);
    int rightDepth = maxDepth(root->right);

    return 1 + (leftDepth > rightDepth ? leftDepth : rightDepth);
}

bool isSameTree(BTNode* p, BTNode* q) {
    if (p == NULL && q == NULL)
    {
        return true;
    }
    if (p == NULL || q == NULL)
    {
        return false;
    }

    if (p->data != q->data)
    {
        return false;
    }

    return isSameTree(p->left, q->left) && isSameTree(p->right, q->right);
}

bool isUnidataTree(BTNode* root) {
    if (root == NULL)
    {
        return true;
    }
    if (root->left == NULL && root->right == NULL)
    {
        return true;
    }

    if (root->left != NULL && root->data != root->left->data)
    {
        return false;
    }
    if (root->right != NULL && root->data != root->right->data)
    {
        return false;
    }

    return isUnidataTree(root->left) && isUnidataTree(root->right);
}